Skip to content

Conversation

@saara-tyagi27
Copy link
Contributor

@saara-tyagi27 saara-tyagi27 commented Jan 13, 2026

Summary

This PR introduces a new validator, test_machine_type_in_zone validator ensures Google Cloud machine type availability via the Compute Engine API prior to deployment. The logic automatically identifies and validates settings matching machine_type suffix against zone across all blueprint modules.

Key Features

  • Automatic Discovery: The validator automatically identifies and validates all module settings matching the machine_type suffix across the entire blueprint.
  • Zone Overrides: If a zone is explicitly provided within a specific module, the validator overrides the global zone for that module's validation logic.
  • Default Validation: The validator has been integrated into the default suite of checks run during blueprint validation.

Warning Handling

A new helper function, handleSoftWarning, has been implemented to manage environment-related API errors.

  • Non-Blocking Errors: For issues like 403 Forbidden (missing permissions) or 400 Bad Request (disabled APIs), the validator issues a console warning and a troubleshooting hint instead of halting the deployment.
  • Skipping Logic: In these cases, the check is skipped to avoid blocking users in restricted environments.

Documentation & Testing

  • Documentation: Updated docs/blueprint-validation.md with comprehensive details on inputs, pass/fail conditions, and manual testing examples.
  • Testing: Added unit tests in pkg/validators/validators_test.go and updated tools/validate_configs/validate_configs.sh to skip the validator during specific automated configuration tests. This skip is necessary because these tests use a placeholder "invalid-project" ID, which would cause the new validator's live API calls to fail

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @saara-tyagi27, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the HPC Toolkit's blueprint validation process by adding a new validator to ensure that all specified Google Cloud machine types are valid and available within their designated zones. This proactive check helps users catch potential configuration errors early, preventing deployment failures and improving the overall reliability of blueprint definitions.

Highlights

  • New Machine Type Validator: Introduced a new validator, testMachineTypeAvailability, which checks if machine types specified in blueprint modules are available in their respective Google Cloud zones.
  • API Integration and Error Handling: The validator integrates with the Google Compute Engine API to query machine type availability. It includes robust error handling, treating API permission issues (403) or disabled APIs (400) as warnings to avoid blocking validation unnecessarily.
  • Blueprint Module Traversal: The validator intelligently traverses blueprint modules, identifies settings related to machine types (e.g., machine_type, _machine_type), resolves their values, and then performs the availability check.
  • Default Validator Inclusion: The new machine type validator is automatically added to the default set of validators that run during blueprint validation, ensuring comprehensive checks by default.
  • Golden Copy Test Exclusion: The test_machine_type_in_zone validator has been explicitly added to the skipped validators list in the validate.sh script for golden copy tests, indicating it's not intended to run in that specific testing context.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new validator to verify that a specified machine type is available in a given zone. This is a valuable addition for preventing deployment failures due to misconfigurations. The implementation correctly iterates through modules, identifies machine type settings, and validates them against the Compute Engine API. My review includes a couple of suggestions to improve a warning message and enhance code formatting for better readability and maintainability.

@saara-tyagi27 saara-tyagi27 marked this pull request as ready for review January 16, 2026 10:09
@saara-tyagi27 saara-tyagi27 requested review from a team and samskillman as code owners January 16, 2026 10:09
@saara-tyagi27 saara-tyagi27 added the release-chore To not include into release notes label Jan 16, 2026
@saara-tyagi27
Copy link
Contributor Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new and valuable validator, test_machine_type_in_zone, to verify Google Cloud machine type availability before deployment. The implementation is well-executed, with automatic discovery of machine types and graceful handling of environmental issues like API or permission errors through a new soft warning mechanism. The accompanying documentation and test updates are thorough and clear. My review includes one suggestion to improve the design of the new warning handling logic for better testability and separation of concerns, in line with the project's goals for technical excellence and maintainability.

inputs:
project_id: $(vars.project_id)
zone: $(vars.zone)
machine_type: c2-standard-60 # any machine type to verify in the zone
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hardcoded machines type here..?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As machine_type is not a global variable in most blueprints, I specified a hardcoded one. But if a global variable is defined that can be referenced as well.

@saara-tyagi27
Copy link
Contributor Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This is a well-executed pull request that introduces a valuable new validator, test_machine_type_in_zone. The implementation is robust, featuring automatic discovery of machine types, intelligent handling of zone overrides, and a thoughtful approach to API errors using soft warnings to avoid blocking deployments unnecessarily. The addition of comprehensive unit tests using a mocked compute service is excellent and ensures the new logic is reliable. The documentation is also clear and thorough. I have one minor suggestion to improve code consistency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-chore To not include into release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants